home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / tex / texsrc.arc / TEX4.C < prev    next >
C/C++ Source or Header  |  1988-09-14  |  54KB  |  2,176 lines

  1. overlay "tex4"
  2. #define EXTERN extern
  3. #include "texd.h"
  4.  
  5. startinput () { /* 30 */ r_startinput 
  6.   scanfilename () ; 
  7.   if ( curext == 206 ) 
  8.   curext = 644 ; 
  9.   packfilename ( curname , curarea , curext ) ; 
  10.   while ( true ) { 
  11.     beginfilerea () ; 
  12.     if ( aopenin ( inputfile [ curinput .indexfield ] , inputpathspec ) ) 
  13.     goto lab30 ; 
  14.     endfilereadi () ; 
  15.     promptfilena ( 640 , 644 ) ; 
  16.   } 
  17.   lab30: curinput .namefield = amakenamestr ( inputfile [ curinput .indexfield 
  18.   ] ) ; 
  19.   if ( jobname == 0 ) 
  20.   {
  21.     jobname = curname ; 
  22.     openlogfile () ; 
  23.   } 
  24.   if ( termoffset + ( strstart [ curinput .namefield + 1 ] - strstart [ 
  25.   curinput .namefield ] ) > maxprintline - 2 ) 
  26.   println () ; 
  27.   else if ( ( termoffset > 0 ) || ( fileoffset > 0 ) ) 
  28.   printchar ( 32 ) ; 
  29.   printchar ( 40 ) ; 
  30.   print ( curinput .namefield ) ; 
  31.   termflush ( output ) ; 
  32.   curinput .statefield = 33 ; 
  33.   {
  34.     if ( ! inputln ( inputfile [ curinput .indexfield ] , false ) ) 
  35.     ; 
  36.     firmupthelin () ; 
  37.     if ( ( eqtb [ 5315 ] .cint < 0 ) || ( eqtb [ 5315 ] .cint > 127 ) ) 
  38.     decr ( curinput .limitfield ) ; 
  39.     else buffer [ curinput .limitfield ] = eqtb [ 5315 ] .cint ; 
  40.     first = curinput .limitfield + 1 ; 
  41.     curinput .locfield = curinput .startfield ; 
  42.     line = 1 ; 
  43.   } 
  44. internalfont zreadfontinfo ( u , nom , aire , s ) 
  45. halfword u ; 
  46. strnumber nom , aire ; 
  47. scaled s ; 
  48. {/* 30 11 45 */ register internalfont Result; 
  49.   r_readfontinfo 
  50.   integer k ; 
  51.   boolean fileopened ; 
  52.   halfword lf, lh, bc, ec, nw, nh, nd, ni, nl, nk, ne, np ; 
  53.   internalfont f ; 
  54.   internalfont g ; 
  55.   eightbits a, b, c, d ; 
  56.   fourquarters qw ; 
  57.   scaled sw ; 
  58.   scaled z ; 
  59.   integer alpha ; 
  60.   quarterword beta ; 
  61.   g = 0 ; 
  62.   fileopened = false ; 
  63.   packfilename ( nom , aire , 664 ) ; 
  64.   if ( ! bopenin ( tfmfile ) ) 
  65.   goto lab11 ; 
  66.   fileopened = true ; 
  67.   {
  68.     {
  69.       lf = tfmtemp ; 
  70.       if ( lf > 127 ) 
  71.       goto lab11 ; 
  72.       tfmtemp = getc ( tfmfile ) ; 
  73.       lf = lf * 256 + tfmtemp ; 
  74.     } 
  75.     tfmtemp = getc ( tfmfile ) ; 
  76.     {
  77.       lh = tfmtemp ; 
  78.       if ( lh > 127 ) 
  79.       goto lab11 ; 
  80.       tfmtemp = getc ( tfmfile ) ; 
  81.       lh = lh * 256 + tfmtemp ; 
  82.     } 
  83.     tfmtemp = getc ( tfmfile ) ; 
  84.     {
  85.       bc = tfmtemp ; 
  86.       if ( bc > 127 ) 
  87.       goto lab11 ; 
  88.       tfmtemp = getc ( tfmfile ) ; 
  89.       bc = bc * 256 + tfmtemp ; 
  90.     } 
  91.     tfmtemp = getc ( tfmfile ) ; 
  92.     {
  93.       ec = tfmtemp ; 
  94.       if ( ec > 127 ) 
  95.       goto lab11 ; 
  96.       tfmtemp = getc ( tfmfile ) ; 
  97.       ec = ec * 256 + tfmtemp ; 
  98.     } 
  99.     if ( ( bc > ec + 1 ) || ( ec > 255 ) ) 
  100.     goto lab11 ; 
  101.     tfmtemp = getc ( tfmfile ) ; 
  102.     {
  103.       nw = tfmtemp ; 
  104.       if ( nw > 127 ) 
  105.       goto lab11 ; 
  106.       tfmtemp = getc ( tfmfile ) ; 
  107.       nw = nw * 256 + tfmtemp ; 
  108.     } 
  109.     tfmtemp = getc ( tfmfile ) ; 
  110.     {
  111.       nh = tfmtemp ; 
  112.       if ( nh > 127 ) 
  113.       goto lab11 ; 
  114.       tfmtemp = getc ( tfmfile ) ; 
  115.       nh = nh * 256 + tfmtemp ; 
  116.     } 
  117.     tfmtemp = getc ( tfmfile ) ; 
  118.     {
  119.       nd = tfmtemp ; 
  120.       if ( nd > 127 ) 
  121.       goto lab11 ; 
  122.       tfmtemp = getc ( tfmfile ) ; 
  123.       nd = nd * 256 + tfmtemp ; 
  124.     } 
  125.     tfmtemp = getc ( tfmfile ) ; 
  126.     {
  127.       ni = tfmtemp ; 
  128.       if ( ni > 127 ) 
  129.       goto lab11 ; 
  130.       tfmtemp = getc ( tfmfile ) ; 
  131.       ni = ni * 256 + tfmtemp ; 
  132.     } 
  133.     tfmtemp = getc ( tfmfile ) ; 
  134.     {
  135.       nl = tfmtemp ; 
  136.       if ( nl > 127 ) 
  137.       goto lab11 ; 
  138.       tfmtemp = getc ( tfmfile ) ; 
  139.       nl = nl * 256 + tfmtemp ; 
  140.     } 
  141.     tfmtemp = getc ( tfmfile ) ; 
  142.     {
  143.       nk = tfmtemp ; 
  144.       if ( nk > 127 ) 
  145.       goto lab11 ; 
  146.       tfmtemp = getc ( tfmfile ) ; 
  147.       nk = nk * 256 + tfmtemp ; 
  148.     } 
  149.     tfmtemp = getc ( tfmfile ) ; 
  150.     {
  151.       ne = tfmtemp ; 
  152.       if ( ne > 127 ) 
  153.       goto lab11 ; 
  154.       tfmtemp = getc ( tfmfile ) ; 
  155.       ne = ne * 256 + tfmtemp ; 
  156.     } 
  157.     tfmtemp = getc ( tfmfile ) ; 
  158.     {
  159.       np = tfmtemp ; 
  160.       if ( np > 127 ) 
  161.       goto lab11 ; 
  162.       tfmtemp = getc ( tfmfile ) ; 
  163.       np = np * 256 + tfmtemp ; 
  164.     } 
  165.     if ( lf != 6 + lh + ( ec - bc + 1 ) + nw + nh + nd + ni + nl + nk + ne + 
  166.     np ) 
  167.     goto lab11 ; 
  168.   } 
  169.   lf = lf - 6 - lh ; 
  170.   if ( np < 7 ) 
  171.   lf = lf + 7 - np ; 
  172.   if ( ( fontptr == fontmax ) || ( fmemptr + lf > fontmemsize ) ) 
  173.   {
  174.     {
  175.       if ( interaction == 3 ) 
  176.       wakeuptermin () ; 
  177.       printnl ( 133 ) ; 
  178.       print ( 655 ) ; 
  179.     } 
  180.     sprintcs ( u ) ; 
  181.     printchar ( 61 ) ; 
  182.     printfilenam ( nom , aire , 206 ) ; 
  183.     if ( s >= 0 ) 
  184.     {
  185.       print ( 598 ) ; 
  186.       printscaled ( s ) ; 
  187.       print ( 262 ) ; 
  188.     } 
  189.     else if ( s != - 1000 ) 
  190.     {
  191.       print ( 656 ) ; 
  192.       printint ( - s ) ; 
  193.     } 
  194.     print ( 665 ) ; 
  195.     {
  196.       helpptr = 4 ; 
  197.       helpline [ 3 ] = 666 ; 
  198.       helpline [ 2 ] = 667 ; 
  199.       helpline [ 1 ] = 668 ; 
  200.       helpline [ 0 ] = 669 ; 
  201.     } 
  202.     error () ; 
  203.     goto lab30 ; 
  204.   } 
  205.   f = fontptr + 1 ; 
  206.   charbase [ f ] = fmemptr - bc ; 
  207.   widthbase [ f ] = charbase [ f ] + ec + 1 ; 
  208.   heightbase [ f ] = widthbase [ f ] + nw ; 
  209.   depthbase [ f ] = heightbase [ f ] + nh ; 
  210.   italicbase [ f ] = depthbase [ f ] + nd ; 
  211.   ligkernbase [ f ] = italicbase [ f ] + ni ; 
  212.   kernbase [ f ] = ligkernbase [ f ] + nl ; 
  213.   extenbase [ f ] = kernbase [ f ] + nk ; 
  214.   parambase [ f ] = extenbase [ f ] + ne ; 
  215.   {
  216.     if ( lh < 2 ) 
  217.     goto lab11 ; 
  218.     {
  219.       tfmtemp = getc ( tfmfile ) ; 
  220.       a = tfmtemp ; 
  221.       qw .b0 = a ; 
  222.       tfmtemp = getc ( tfmfile ) ; 
  223.       b = tfmtemp ; 
  224.       qw .b1 = b ; 
  225.       tfmtemp = getc ( tfmfile ) ; 
  226.       c = tfmtemp ; 
  227.       qw .b2 = c ; 
  228.       tfmtemp = getc ( tfmfile ) ; 
  229.       d = tfmtemp ; 
  230.       qw .b3 = d ; 
  231.       fontcheck [ f ] = qw ; 
  232.     } 
  233.     tfmtemp = getc ( tfmfile ) ; 
  234.     {
  235.       z = tfmtemp ; 
  236.       if ( z > 127 ) 
  237.       goto lab11 ; 
  238.       tfmtemp = getc ( tfmfile ) ; 
  239.       z = z * 256 + tfmtemp ; 
  240.     } 
  241.     tfmtemp = getc ( tfmfile ) ; 
  242.     z = z * 256 + tfmtemp ; 
  243.     tfmtemp = getc ( tfmfile ) ; 
  244.     z = ( z * 16 ) + ( tfmtemp / 16 ) ; 
  245.     if ( z < 65536 ) 
  246.     goto lab11 ; 
  247.     while ( lh > 2 ) { 
  248.       tfmtemp = getc ( tfmfile ) ; 
  249.       tfmtemp = getc ( tfmfile ) ; 
  250.       tfmtemp = getc ( tfmfile ) ; 
  251.       tfmtemp = getc ( tfmfile ) ; 
  252.       decr ( lh ) ; 
  253.     } 
  254.     fontdsize [ f ] = z ; 
  255.     if ( s != - 1000 ) 
  256.     if ( s >= 0 ) 
  257.     z = s ; 
  258.     else z = xnoverd ( z , - s , 1000 ) ; 
  259.     fontsize [ f ] = z ; 
  260.   } 
  261.   for ( k = fmemptr ; k <= widthbase [ f ] - 1 ; k ++ ) 
  262.   {
  263.     {
  264.       tfmtemp = getc ( tfmfile ) ; 
  265.       a = tfmtemp ; 
  266.       qw .b0 = a ; 
  267.       tfmtemp = getc ( tfmfile ) ; 
  268.       b = tfmtemp ; 
  269.       qw .b1 = b ; 
  270.       tfmtemp = getc ( tfmfile ) ; 
  271.       c = tfmtemp ; 
  272.       qw .b2 = c ; 
  273.       tfmtemp = getc ( tfmfile ) ; 
  274.       d = tfmtemp ; 
  275.       qw .b3 = d ; 
  276.       fontinfo [ k ] .qqqq = qw ; 
  277.     } 
  278.     if ( ( a >= nw ) || ( b / 16 >= nh ) || ( b % 16 >= nd ) || ( c / 4 >= ni 
  279.     ) ) 
  280.     goto lab11 ; 
  281.     switch ( c % 4 ) 
  282.     {case 1 : 
  283.       if ( d >= nl ) 
  284.       goto lab11 ; 
  285.       break ; 
  286.     case 3 : 
  287.       if ( d >= ne ) 
  288.       goto lab11 ; 
  289.       break ; 
  290.     case 2 : 
  291.       {
  292.     {
  293.       if ( ( d < bc ) || ( d > ec ) ) 
  294.       goto lab11 ; 
  295.     } 
  296.     while ( d < k + bc - fmemptr ) { 
  297.       qw = fontinfo [ charbase [ f ] + d ] .qqqq ; 
  298.       if ( ( ( qw .b2 ) % 4 ) != 2 ) 
  299.       goto lab45 ; 
  300.       d = qw .b3 ; 
  301.     } 
  302.     if ( d == k + bc - fmemptr ) 
  303.     goto lab11 ; 
  304.     lab45: ; 
  305.       } 
  306.       break ; 
  307.     default : 
  308.       ; 
  309.       break ; 
  310.     } 
  311.   } 
  312.   {
  313.     {
  314.       alpha = 16 ; 
  315.       while ( z >= 8388608 ) { 
  316.     z = z / 2 ; 
  317.     alpha = alpha + alpha ; 
  318.       } 
  319.       beta = 256 / alpha ; 
  320.       alpha = alpha * z ; 
  321.     } 
  322.     for ( k = widthbase [ f ] ; k <= ligkernbase [ f ] - 1 ; k ++ ) 
  323.     {
  324.       tfmtemp = getc ( tfmfile ) ; 
  325.       a = tfmtemp ; 
  326.       tfmtemp = getc ( tfmfile ) ; 
  327.       b = tfmtemp ; 
  328.